import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'

//引入自动导包
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
//引入element-plus
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  server:{
    host:'0.0.0.0',
    port:9090,
    proxy:{
      '/api':{
        target:'http://localhost:3000',
        changeOrigin:true,
        rewrite:path=>path.replace(/^\/api/,'')
      }
    }
  },
  resolve:{
    alias:{
      '@':path.resolve(__dirname,'src')
    },
    extensions: [".css",".scss",".js", ".ts", ".tsx", ".jsx"],
  },
  css:{
    preprocessorOptions:{
      scss:{
        additionalData:`@import "@/assets/sass/index.scss";@import "@/assets/sass/common.scss";`,
      }
    }
  }
})
